/*******************************************************************************
 * Copyright (c) 2022, 2022
 ******************************************************************************/
package com.alex.demo.mybatisplus.handler;

import java.util.Date;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;

import lombok.extern.slf4j.Slf4j;

/**
 * @Version 1.0
 * @Author zepei.tao
 * @Created Dec 2022/1/3 23:16
 * @Description
 *              <p>
 * @Modification
 *               <p>
 *               Date Author Version Description
 *               <p>
 *               2022/1/3 zepei.tao 1.0 create file
 */
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

	// 插入时的填充策略
	@Override
	public void insertFill(MetaObject metaObject) {
		log.info("start insert fill.....");
		this.setFieldValByName("createTime", new Date(), metaObject);
		this.setFieldValByName("updateTime", new Date(), metaObject);
	}

	// 更新时的填充策略
	@Override
	public void updateFill(MetaObject metaObject) {
		log.info("start update fill.....");
		this.setFieldValByName("updateTime", new Date(), metaObject);
	}
}
